package cz.boxdesign.library.web.validation;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import cz.boxdesign.library.web.view.UserView;

public class UserValidator implements Validator {

  @Override
  public boolean supports(Class<?> clazz) {
    return clazz == UserView.class;
  }

  @Override
  public void validate(Object target, Errors errors) {
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "jmeno", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "prijmeni", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors,"login" , "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ulice", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "mesto", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "psc", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "plat", "field.required");
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "rodneCislo", "field.required");
  }

}
